using System;
using App_Code.Modules;
using Portal.Core;
using Portal.Data.Entity;
using Portal.Core.Binding;
public partial class Modules_Category_New : CategoryModule
{
    protected override string Action
    {
        get
        {
            return "newed";
        }
    }
    private Category _category;
    protected Category NewCategory
    {
        get
        {
            if (_category == null)
            {
                object obj = Binder.GetData(typeof(Category), phContent, new BindContext());
                if (obj != null)
                {
                    _category = (Category)obj;
                }
            }
            return _category;
        }
    }
    protected override void OnLoad(EventArgs e)
    {
        if(!IsPostBack)
        {
            Parent_ID.DataSource = Category.FindAllForAdminInTree();
            Parent_ID.DataBind();

            Status.DataSource = ObjectStatusClass.ListAll();
            Status.DataBind();
            Status.SelectedValue = (int)ObjectStatusClass.CommonStatus.Active+"";

            CateType.DataSource = ObjectTypeClass.ListAll();
            CateType.DataBind();

            var catid = Request["catid"];
            if (catid != null)
                Parent_ID.SelectedValue = catid;
        }
    }

    protected override void Save_Click(object sender, System.EventArgs e)
    {
        NewCategory.ListPage_ID = WebpartPage.CreateNewPage().ID;
        NewCategory.DetailPage_ID = WebpartPage.CreateNewPage().ID;
        NewCategory.Save();
        Forward("save");
    }
}
